home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
C
/
ownlib.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-10-30
|
5KB
|
205 lines
/****************************************************************
* *
* Copyright 1985, Commodore Amiga Inc. All rights reserved. *
* No part of this program may be reproduced, transmitted, *
* transcribed, stored in retrieval system, or translated into *
* any language or computer language, in any form or by any *
* means, electronic, mechanical, magnetic, optical, chemical, *
* manual or otherwise, without the prior written permission of *
* Commodore Amiga Incorporated, 983 University Ave, #D *
* Los Gatos, CA 95030 *
* *
****************************************************************/
/*** library.asm ***/
*** Info Library Interface Functions ***
*------ Included Files -----------------------------------------------
INCLUDE 'exec/types.i'
INCLUDE 'exec/nodes.i'
INCLUDE 'exec/lists.i'
INCLUDE 'exec/memory.i'
INCLUDE 'exec/ports.i'
INCLUDE 'exec/libraries.i'
INCLUDE 'exec/devices.i'
INCLUDE 'exec/tasks.i'
INCLUDE 'exec/io.i'
INCLUDE 'exec/strings.i'
INCLUDE 'exec/initializers.i'
INCLUDE 'exec/resident.i'
*------ Imported Globals ---------------------------------------------
*------ Imported Functions -------------------------------------------
XREF _main
XREF _InfoOpen
XREF _InfoClose
XREF _InfoExpunge
*------ Exported Globals ---------------------------------------------
XDEF _SysBase
XDEF _InfoBase
XDEF _InfoSegList
XDEF _InfoName
*------ Exported Functions -------------------------------------------
InfoTag:
DC.W RTC_MATCHWORD
DC.L InfoTag
DC.L EndMarker
DC.B RTF_AUTOINIT
DC.B 1 version
DC.B NT_LIBRARY
DC.B 0 priority
DC.L _InfoName
DC.L _InfoIdStr
DC.L InfoInit
_InfoIdStr DC.B 'info V1.0',13,10,0
DS.W 0
InfoInit:
DC.L LIB_SIZE
DC.L libFuncInit
DC.L libStructInit
DC.L init
init:
;------ This is called from within MakeLibrary, after
; all the memory has been allocated
move.l a6,_SysBase
move.l d0,_InfoBase
move.l a0,_InfoSegList
rts
libStructInit:
INITBYTE LN_TYPE,NT_LIBRARY
INITLONG LN_NAME,_InfoName
INITWORD LIB_VERSION,1
INITLONG LIB_IDSTRING,_InfoIdStr
* INITBYTE LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
DC.W 0
libFuncInit:
DC.L open
DC.L close
DC.L expunge
DC.L extfunc
DC.L _main
DC.L -1
open:
move.l a6,-(sp)
jsr _InfoOpen
addq.l #4,sp
rts
close:
move.l a6,-(sp)
jsr _InfoClose
addq.l #4,sp
rts
expunge:
move.l a6,-(sp)
jsr _InfoExpunge
addq.l #4,sp
extfunc:
rts
_SysBase DC.L 0
_InfoBase DC.L 0
_InfoSegList DC.L 0
_InfoName DC.B 'info.library',0
DS.W 0
EndMarker
END
/*** libcode.c ***/
#include "exec/types.h"
#include "exec/libraries.h"
extern APTR InfoSegList;
struct Library *
InfoOpen(lib)
struct Library *lib;
{
kprintf ("opening...\n");
lib -> lib_Flags &= ~LIBF_DELEXP;
(lib -> lib_OpenCnt)++;
return lib;
}
APTR
InfoExpunge(lib)
struct Library *lib;
{
APTR seglist;
kprintf ("expunging...\n");
Forbid ();
if (lib -> lib_OpenCnt > 0) {
lib -> lib_Flags |= LIBF_DELEXP;
Permit ();
return 0;
}
seglist = InfoSegList;
kprintf ("seglist= %lx", seglist);
Remove (lib);
FreeMem ((long) lib - (long) (lib -> lib_NegSize),
(lib -> lib_NegSize + lib -> lib_PosSize));
Permit ();
return seglist;
}
APTR
InfoClose(lib)
struct Library *lib;
{
kprintf ("closing...\n");
if (--(lib -> lib_OpenCnt) == 0) {
if ((lib -> lib_Flags & LIBF_DELEXP) != 0) {
return (InfoExpunge (lib));
}
}
return 0;
}
main()
{
kprintf ("main info program\n");
}